export const code = `import React, { useState, forwardRef } from "react";
import CodeDisplayPage from "../../components/CodePreview";
import { Button, Checkbox, Col, Row } from "antd";
import useFetch from "./myCompare";
import {code} from "./utils"; 
// 使用
function UserList() {
  const [datalist, setDatalist] = useState({ name: 1, age: 2 });
  const { data } = useFetch(datalist);

  const handleClick = async () => {
    const obj = { name: datalist.name + 1, age: datalist.age + 1 };
    setDatalist(obj);
  };
  return (
    <div>
      <Button onClick={handleClick}>请求测试</Button>
      <div>{data}</div>
      <CodeDisplayPage code={code} language={"tsx"} />
    </div>
  );
}
export default UserList;
`;

export const schema={
  "$schema": "http://json-schema.org/draft-07/schema#",
  "definitions": {
    "specs": {
      "title": "资源规格",
      "type": "string",
      "description": "CPU和内存的单位是核和Gi,GPU的单位是卡",
      "oneOf": [
        {
          "title": "nvidia.com/a100.80g(16c128g)",
          "const": "nvidia.com/a100.80g"
        },
        {
          "title": "nvidia.com/a100.40g",
          "const": "nvidia.com/a100.40g"
        },
        {
          "title": "nvidia.com/1080ti",
          "const": "nvidia.com/1080ti"
        },
        {
          "title": "tiny规格",
          "const": "tiny"
        },
        {
          "title": "small规格",
          "const": "small"
        },
        {
          "title": "middle规格",
          "const": "middle"
        },
        {
          "title": "large规格",
          "const": "large"
        },
        {
          "title": "big(32C128G)",
          "const": "big"
        },
        {
          "title": "middle计算型规格",
          "const": "middle-compute"
        },
        {
          "title": "huge规格",
          "const": "huge"
        },
        {
          "title": "测试",
          "const": "xxc"
        }
      ]
    },
    "pvcs": {
      "title": "存储卷",
      "description": "CephFS存储卷,一般会默认挂载到 `/mnt/${name}` ，读写权限在磐石进行申请。"
    },
    "cfgs": {
      "title": "配置项",
      "description": "配置项默认挂载到 `/mnt/${name}/${name}`，只要读权限"
    },
    "hadoopQueues": {}
  },
  "properties": {
    "application": {
      "additionalProperties": true,
      "properties": {
        "job": {
          "properties": {
            "advanced": {
              "allOf": [
                {
                  "if": {
                    "properties": {
                      "enabled": {
                        "const": true,
                        "required": []
                      }
                    },
                    "required": []
                  },
                  "required": [],
                  "then": {
                    "properties": {
                      "parallelism": {
                        "default": 1,
                        "description": "同时最多启动多少节点执行任务",
                        "maximum": 100,
                        "minimum": 1,
                        "required": [],
                        "title": "并行度",
                        "type": "number"
                      },
                      "retries": {
                        "default": 3,
                        "description": "任务失败允许重试次数",
                        "required": [],
                        "title": "重试次数",
                        "type": "number"
                      },
                      "timeouts": {
                        "default": 259200,
                        "description": "任务超时失败时间，单位`秒`, 默认3天。",
                        "required": [],
                        "title": "超时时间",
                        "type": "number"
                      }
                    },
                    "required": []
                  }
                }
              ],
              "properties": {
                "enabled": {
                  "default": false,
                  "required": [],
                  "title": "开启高级配置",
                  "type": "boolean"
                }
              },
              "required": [],
              "title": "任务高级配置",
              "type": "object"
            },
            "bigData": {
              "allOf": [
                {
                  "if": {
                    "properties": {
                      "enabled": {
                        "const": true,
                        "required": []
                      }
                    },
                    "required": []
                  },
                  "required": [],
                  "then": {
                    "properties": {
                      "enableHive": {
                        "default": false,
                        "required": [],
                        "title": "是否启用Hive",
                        "type": "boolean"
                      },
                      "enableSpark": {
                        "default": false,
                        "required": [],
                        "title": "是否启用Spark",
                        "type": "boolean"
                      },
                      "queue": {
                        "$ref": "#/definitions/hadoopQueues",
                        "required": [],
                        "title": "大数据队列"
                      }
                    },
                    "required": []
                  }
                }
              ],
              "properties": {
                "enabled": {
                  "default": false,
                  "required": [],
                  "title": "是否启用大数据环境",
                  "type": "boolean"
                }
              },
              "required": [],
              "title": "大数据环境配置",
              "type": "object"
            },
            "command": {
              "properties": {
                "args": {
                  "default": "",
                  "description": "执行参数, 会传递给执行脚本，参数为字符串数组, 例如: `script.sh arg1 arg2 ...`。",
                  "items": {
                    "required": [],
                    "type": "string"
                  },
                  "required": [],
                  "title": "脚本参数",
                  "type": "array"
                },
                "interpreter": {
                  "default": "bash",
                  "enum": [
                    "bash",
                    "python",
                    "sh"
                  ],
                  "required": [],
                  "title": "解释器"
                },
                "kwargs": {
                  "default": "",
                  "description": "执行关键词参数, 会传递给执行脚本,例如: `karg1=val1 karg2=val2 script.sh`。",
                  "items": {
                    "properties": {
                      "name": {
                        "description": "参数名称",
                        "pattern": "^(\\w|-)+$",
                        "required": [],
                        "type": "string"
                      },
                      "value": {
                        "description": "参数值",
                        "pattern": "^(\\w|-)+$",
                        "required": [],
                        "type": "string"
                      }
                    },
                    "required": [],
                    "type": "object"
                  },
                  "required": [],
                  "title": "关键词参数",
                  "type": "array"
                },
                "script": {
                  "default": "",
                  "description": "执行脚本, 脚本必须与解释器匹配。 例如 `/mnt/xxx_pvc/xxx.sh`",
                  "required": [],
                  "title": "执行脚本",
                  "type": "string"
                }
              },
              "required": [
                "interpreter",
                "script"
              ],
              "title": "任务命令",
              "type": "object"
            },
            "env": {
              "description": "任务环境变量",
              "items": {
                "properties": {
                  "name": {
                    "description": "环境变量名称,字母、数字",
                    "pattern": "^(\\w|-)+$",
                    "required": [],
                    "type": "string"
                  },
                  "value": {
                    "description": "环境变量值",
                    "pattern": "^(\\w|-)+$",
                    "required": [],
                    "type": "string"
                  }
                },
                "required": [],
                "type": "object"
              },
              "required": [],
              "title": "环境变量",
              "type": "array"
            },
            "image": {
              "allOf": [
                {
                  "if": {
                    "properties": {
                      "advanced": {
                        "const": true,
                        "required": []
                      }
                    },
                    "required": []
                  },
                  "required": [],
                  "then": {
                    "properties": {
                      "registry": {
                        "default": "harbor-library",
                        "description": "镜像仓库,默认使用`harbor-library`, 如果需要自定义请选择`custom`.",
                        "enum": [
                          "harbor-library",
                          "custom"
                        ],
                        "required": [],
                        "title": "镜像源"
                      }
                    },
                    "required": []
                  }
                },
                {
                  "if": {
                    "properties": {
                      "advanced": {
                        "const": true,
                        "required": []
                      },
                      "registry": {
                        "const": "custom",
                        "required": []
                      }
                    },
                    "required": []
                  },
                  "required": [],
                  "then": {
                    "properties": {
                      "repository": {
                        "description": "自定义镜像源地址，例如： harbor.musicdata-gz.netease.com/library.",
                        "required": [],
                        "title": "镜像源地址",
                        "type": "string"
                      }
                    },
                    "required": []
                  }
                },
                {
                  "if": {
                    "properties": {
                      "advanced": {
                        "const": true,
                        "required": []
                      },
                      "registry": {
                        "const": "harbor-library",
                        "required": []
                      }
                    },
                    "required": []
                  },
                  "required": [],
                  "then": {
                    "properties": {
                      "repository": {
                        "default": "harbor.musicdata-gz.netease.com/library",
                        "description": "磐石Harbor镜像源，harbor.musicdata-gz.netease.com/library",
                        "enum": [
                          "harbor.musicdata-gz.netease.com/library"
                        ],
                        "required": [],
                        "title": "镜像源地址"
                      }
                    },
                    "required": []
                  }
                }
              ],
              "properties": {
                "advanced": {
                  "default": false,
                  "required": [],
                  "title": "其他配置",
                  "type": "boolean"
                },
                "name": {
                  "default": "",
                  "description": "镜像名称以及版本，例如：`ironman-ntf1.15.5-gpu-py38:3.2.5`",
                  "required": [],
                  "title": "镜像名称",
                  "type": "string"
                }
              },
              "required": [
                "name"
              ],
              "title": "镜像配置",
              "type": "object"
            },
            "resource": {
              "properties": {
                "spec": {
                  "$ref": "#/definitions/specs",
                  "required": []
                }
              },
              "required": [],
              "title": "资源规格",
              "type": "object"
            },
            "schedule": {
              "allOf": [
                {
                  "if": {
                    "properties": {
                      "enabled": {
                        "const": true,
                        "required": []
                      }
                    },
                    "required": []
                  },
                  "required": [],
                  "then": {
                    "properties": {
                      "concurrencyPolicy": {
                        "default": "Allow",
                        "description": "调度并发策略, 例如: `Allow`允许并发，`Forbid`禁止并发，`Replace`替换正在运行的任务。",
                        "enum": [
                          "Allow",
                          "Forbid",
                          "Replace"
                        ],
                        "required": [],
                        "title": "调度并发策略"
                      },
                      "cron": {
                        "description": "crontab调度表达式, 例如: 每天凌晨1点执行( * 1 * * * ), 每十分钟执行一次( */10 * * * * )，参考: https://crontab.guru/",
                        "required": [],
                        "title": "调度表达式",
                        "type": "string"
                      },
                      "deadlineSeconds": {
                        "default": 86400,
                        "description": "当调度延迟超过该时间，任务将被标记为失败，单位`秒`, 默认1天。",
                        "required": [],
                        "title": "调度延迟时间",
                        "type": "number"
                      },
                      "suspend": {
                        "default": false,
                        "description": "是否暂停调度, 默认为`false`, 即不暂停调度。",
                        "required": [],
                        "title": "是否暂停调度",
                        "type": "boolean"
                      }
                    },
                    "required": []
                  }
                }
              ],
              "properties": {
                "enabled": {
                  "default": false,
                  "required": [],
                  "title": "是否启用调度",
                  "type": "boolean"
                }
              },
              "required": [],
              "title": "任务调度配置",
              "type": "object"
            }
          },
          "required": [
            "image",
            "resource"
          ],
          "title": "容器任务配置",
          "type": "object"
        },
        "volumes": {
          "description": "卷挂载配置,指定的卷会在Server跟Worker同时挂载，支持: HostPath, CephFS, EmptyDir, ConfigMap",
          "items": {
            "allOf": [
              {
                "if": {
                  "properties": {
                    "volumeType": {
                      "const": "CephFS",
                      "required": []
                    }
                  },
                  "required": []
                },
                "required": [],
                "then": {
                  "properties": {
                    "name": {
                      "$ref": "#/definitions/pvcs",
                      "required": []
                    }
                  },
                  "required": []
                }
              },
              {
                "if": {
                  "properties": {
                    "volumeType": {
                      "const": "EmptyDir",
                      "required": []
                    }
                  },
                  "required": []
                },
                "required": [],
                "then": {
                  "properties": {
                    "medium": {
                      "default": "",
                      "description": "当选择Memory媒介时使用共享内存, 默认使用宿主机临时目录存储，容器重启数据丢失。",
                      "enum": [
                        "",
                        "Memory"
                      ],
                      "required": []
                    },
                    "mountPath": {
                      "description": "Memory类型媒介请挂载到: /dev/shm",
                      "required": [],
                      "title": "挂载点",
                      "type": "string"
                    },
                    "name": {
                      "pattern": "^(\\w|-)+$",
                      "required": [],
                      "title": "名称",
                      "type": "string"
                    },
                    "sizeLimit": {
                      "default": "5Gi",
                      "description": "EmptyDir类型卷的大小限制",
                      "pattern": "^[A-Za-z0-9]+$",
                      "required": [],
                      "type": "string"
                    }
                  },
                  "required": []
                }
              },
              {
                "if": {
                  "properties": {
                    "volumeType": {
                      "const": "HostPath",
                      "required": []
                    }
                  },
                  "required": []
                },
                "required": [],
                "then": {
                  "properties": {
                    "hostPath": {
                      "description": "HostPath类型卷在宿主机中的路径，将宿主机上的目录挂载到容器中使用",
                      "required": [],
                      "type": "string"
                    },
                    "mountPath": {
                      "required": [],
                      "title": "挂载点",
                      "type": "string"
                    },
                    "name": {
                      "pattern": "^(\\w|-)+$",
                      "required": [],
                      "title": "名称",
                      "type": "string"
                    },
                    "readOnly": {
                      "required": [],
                      "title": "只读",
                      "type": "boolean"
                    }
                  },
                  "required": []
                }
              }
            ],
            "properties": {
              "volumeType": {
                "default": "CephFS",
                "description": "挂载卷类型",
                "enum": [
                  "CephFS",
                  "HostPath",
                  "EmptyDir",
                  "ConfigMap"
                ],
                "required": []
              }
            },
            "required": [
              "volumeType"
            ],
            "type": "object"
          },
          "required": [],
          "title": "卷挂载配置",
          "type": "array"
        }
      },
      "required": [
        "job"
      ],
      "title": "应用配置",
      "type": "object"
    }
  },
  "required": [
    "application"
  ],
  "type": "object"
}


export const  uiSchema={
  "application": {
    "headlineType": "H1",
    "job": {
      "advanced": {
        "ui:options": {
          "expandable": false
        },
        "ui:order": [
          "enabled",
          "parallelism",
          "timeouts",
          "retries",
          "*"
        ]
      },
      "bigData": {
        "headlineType": "H3",
        "ui:options": {
          "expandable": false
        },
        "ui:order": [
          "enabled",
          "queue",
          "enableHive",
          "enableSpark",
          "*"
        ]
      },
      "command": {
        "headlineType": "H3",
        "ui:options": {
          "expandable": false
        },
        "ui:order": [
          "interpreter",
          "script",
          "args",
          "kwargs",
          "*"
        ]
      },
      "headlineType": "H2",
      "image": {
        "headlineType": "H3",
        "ui:options": {
          "expandable": false
        },
        "ui:order": [
          "name",
          "advanced",
          "registry",
          "path",
          "*"
        ]
      },
      "schedule": {
        "headlineType": "H3",
        "ui:options": {
          "expandable": false
        },
        "ui:order": [
          "enabled",
          "cron",
          "suspend",
          "deadlineSeconds",
          "concurrencyPolicy",
          "*"
        ]
      },
      "ui:options": {
        "expandable": false
      },
      "ui:order": [
        "image",
        "resource",
        "env",
        "command",
        "schedule",
        "bigData",
        "advanced",
        "*"
      ]
    },
    "ui:options": {
      "expandable": false
    },
    "ui:order": [
      "job",
      "volumes",
      "*"
    ]
  },
  "ui:order": [
    "application",
    "*"
  ]
}

export const formData={
  "application": {
    "job": {
      "advanced": {
        "enabled": false,
        "parallelism": 1,
        "retries": 3,
        "timeouts": 259200
      },
      "bigData": {
        "enabled": true,
        "enableHive": true,
        "enableSpark": true,
        "queue": "music_datahub"
      },
      "command": {
        "args": [
          "arg1",
          "arg2"
        ],
        "interpreter": "bash",
        "kwargs": [
          {
            "name": "kwarg1",
            "value": "kval1"
          },
          {
            "name": "kwarg2",
            "value": "kval2"
          }
        ],
        "script": "/mnt/lixuedong-dev/job/test.sh"
      },
      "env": [
        {
          "name": "env1",
          "value": "val1"
        },
        {}
      ],
      "image": {
        "advanced": false,
        "name": "jupyter-tf1.14.0-gpu-py37-hadoop:v3.21",
        "registry": "harbor-library",
        "repository": "harbor.musicdata-gz.netease.com/library"
      },
      "resource": {
        "spec": "tiny"
      },
      "schedule": {
        "enabled": false,
        "concurrencyPolicy": "Allow",
        "deadlineSeconds": 86400,
        "suspend": false
      }
    },
    "volumes": [
      {
        "volumeType": "CephFS",
        "monitors": [
          "10.48.32.20:6789",
          "10.48.32.21:6789",
          "10.48.32.22:6789"
        ],
        "mountPath": "/mnt/lixuedong-dev",
        "name": "lixuedong-dev",
        "path": "/volumes/csi/hdd-ad7e0534-fa50-11ef-a20b-162e14cabaee/0a97a5d9-be77-4e84-9418-3e9adf0f5852",
        "readOnly": false,
        "secret": "ceph-secret-admin-goblin",
        "user": "admin"
      }
    ]
  }
}